﻿@{
    ViewBag.Title = "Filepload";
}
<link href="/Scripts/uploadify-v2.1.4/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/Scripts/uploadify-v2.1.4/swfobject.js"></script>
<script src="/Scripts/uploadify-v2.1.4/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
<div id="fileQueue">
</div>
<input type="file" name="uploadify" id="uploadify" />
<input type="text" id="hdImgUrl" />
<div id="img">
</div>
<p>
    <a href="javascript:$('#uploadify').uploadifyUpload();">上传</a>| <a href="javascript:$('#uploadify').uploadifyClearQueue();">
        取消上传</a>
</p>
<script type="text/javascript">
    $("#uploadify").uploadify({
        'uploader': '/Scripts/uploadify-v2.1.4/uploadify.swf',
        'script': '/ashx/Upload.ashx',
        'cancelImg': '/Scripts/uploadify-v2.1.4/cancel.png',
        'folder': '/UploadFile',
        'queueID': 'fileQueue',
        'auto': false,
        'multi': true,
        'fileExt': '*.jpg;*gif;*png;',
        'fileDesc': 'Image Files (.jpg, .gif, .png)',
        'onComplete': function (event, queueId, fileObj, response, data) {
            var ary = response.split('|');
            if (ary[0] == "0") {
                Boxy.alert('上传失败，请重新上传', null, { title: "提示信息" });
            }
            else {
                //path资源地址
                if (ary.length == 2) {
                    $("#hdImgUrl").val($("#hdImgUrl").val());
                    $("#img").append("<img src='" + ary[1] + "'>");

                } else {
                    alert("error");
                }

            }
        }
    });
</script>
